#!/bin/sh

checkdep () {
    $1 --help 2>/dev/null >/dev/null
    [ $? -eq 127 ] && return 1 || return 0
}

findmake () {
    make=""
    checkdep make ; [ $? -eq 0 ] && make="make"
    checkdep gmake ; [ $? -eq 0 ] && make="gmake"
    echo $make
}

MAKE=`findmake`
[ "$MAKE" = "" ] && {
        echo "**************** ERROR ***********************"
        echo "make or gmake don't seem to be installed"
        echo "you need a make command into your PATH"
        echo "**********************************************"
        exit
}

if [ -d /usr/local/lib/yaws ]
then
	echo "Yaws already installed"
else
	cd yaws-1.68
	mkdir bin 2>/dev/null
	mkdir ebin 2>/dev/null
	mkdir -p examples/ebin 2>/dev/null
	chmod +x scripts/*
	sh configure
	$MAKE
	$MAKE install
fi